package com.zh.mapstruct;

import com.zh.pojo.domain.Order;
import com.zh.pojo.domain.OrderBill;
import com.zh.pojo.domain.OrderProfitsharing;
import com.zh.pojo.dto.OrderDto;
import com.zh.pojo.result.OrderCalculateResult;
import com.zh.pojo.result.ProfitSharingResult;
import com.zh.pojo.vo.KillOrderVo;
import com.zh.pojo.vo.OrderBillVO;
import com.zh.pojo.vo.OrderDetailForCustomerVO;
import com.zh.pojo.vo.OrderLocationVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * Login 对象转换 映射结构
 */

@Mapper
public interface OrderStructMapper {
    OrderStructMapper INSTANCE = Mappers.getMapper(OrderStructMapper.class);

    // OrderDto 对象 转换为 Order对象
    Order orderDtoConvertOrder(OrderDto orderDto);

    @Mappings({
            @Mapping(source = "order.id",target = "orderId"),
            @Mapping(source = "order.remark",target = "orderDetail"),
            @Mapping( source = "orderCalculateResult.returnMileage",target = "returnMileage"),
    })
    OrderBill orderAndorderCalculateResultConvertOrderBill(Order order, OrderCalculateResult orderCalculateResult);
    @Mappings({
            @Mapping(source = "order.startPlaceLatitude",target = "startLatitude"),
            @Mapping(source = "order.startPlaceLongitude",target = "startLongitude"),
            @Mapping(source = "order.endPlaceLatiude",target = "endLatitude"),
            @Mapping( source = "order.endPlaceLongitude",target = "endLongitude", ignore = true),
    })
    KillOrderVo orderConvertKillOrderVo(Order order);
    OrderLocationVo orderConvertKillOrderLocationVo(Order order);
    void updateOrderBillFromOrderCalculateResult(OrderCalculateResult orderCalculateResult, @MappingTarget OrderBill orderBill);

    @Mappings({
            @Mapping(source = "order.id",target = "id", ignore = true),
            @Mapping(source = "order.id",target = "orderId"),
            @Mapping(source = "order.realOrderAmount",target = "orderAmount"),
    })
    OrderProfitsharing orderAndprofitSharingConvertOrderProfitsharing(Order order, ProfitSharingResult profitSharingResult);


    OrderBillVO orderBillAndorderProfitsharingConvertOrderBillVO(OrderBill orderBill, OrderProfitsharing orderProfitsharing);
    @Mappings({
            @Mapping(source = "order.realOrderAmount",target = "realOrderAmount"),
            @Mapping(source = "orderBill.returnMileage",target = "returnMileage"),
            @Mapping(source = "order.orderNo",target = "orderNo"),
            @Mapping(source = "order.createTime",target = "createTime"),
            @Mapping(source = "orderBill.favourAmount",target = "favourAmount"),
    })
    OrderDetailForCustomerVO orderBillAndOrderConvertOrderBillVO(Order order, OrderBill orderBill);
}
